package com.mvc.web.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mvc.web.common.utils.ToolsUtils;
import com.mvc.web.user.dao.UserDao;
import com.mvc.web.user.service.UserService;
import com.mvc.web.user.vo.LoginForm;
import com.mvc.web.user.vo.UserVo;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserDao userDao;

	@Override
	public UserVo getUser(LoginForm vo) {
		return userDao.getUser(vo);
	}

	@Override
	public void getVeridyCode(String phone, int verifyCode, long tokenTime) {
		String uid = userDao.getCountByPhone(phone);
		//新注册
		if(ToolsUtils.isEmpty(uid)){
			userDao.createUser(phone,verifyCode,tokenTime);
		}else{
			userDao.updateUser(phone,verifyCode,tokenTime);
		}
	}

	@Override
	public void uploadImage(int uid, String imgUrl) {
		userDao.uploadImage(uid,imgUrl);
	}

	@Override
	public void setPwd(int uid, String newPwd) {
		userDao.setPwd(uid,newPwd);
	}
}
